import os
import sys

# 请在此输入您的代码
n,q = map(int,input().split())
stones = [0 for _ in range(n)]
for _ in range(q):
  t,x,y = map(int,input().split())
  if t == 1:
    for i in range(0,x):
      stones[i] += y
  else:
    for i in range(q-1,q-x,-1):
      stones[i] -= y

print(max(stones))
